package com.thprojects.myphotomemories.controller;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;

import com.thprojects.myphotomemories.model.Album;
import com.thprojects.myphotomemories.model.Photo;
import com.thprojects.myphotomemories.view.AlbumView;
import com.thprojects.myphotomemories.view.CreateAlbumView;
import com.thprojects.myphotomemories.view.DrawPhotoView;
import com.thprojects.myphotomemories.view.EffectsPhotoView;
import com.thprojects.myphotomemories.view.MyPhotoMemoriesActivity;
import com.thprojects.myphotomemories.view.PhotoDetailsEdit;
import com.thprojects.myphotomemories.view.PhotoDetailsView;
import com.thprojects.myphotomemories.view.PhotoView;
import com.thprojects.myphotomemories.view.RotatePhotoView;
import com.thprojects.myphotomemories.view.ShareFbView;

public class GuiController {
	public static void showCreateAlbum(Context c){
		Intent intent = new Intent(c, CreateAlbumView.class);
		c.startActivity(intent);
	}
	
	public static void showMain(Context c){
		Intent intent = new Intent(c, MyPhotoMemoriesActivity.class);
		c.startActivity(intent);
	}
	
	public static void showAlbum(Context c, Album a){
		Intent intent = new Intent(c, AlbumView.class);
		intent.putExtra("album", a);
		c.startActivity(intent);
	}
	
	public static void showPhotoDetails(Context c, String filePath, Album a){
		Intent intent = new Intent(c, PhotoDetailsView.class);
		intent.putExtra("filePath", filePath);
		intent.putExtra("album", a);
		c.startActivity(intent);
	}
	
	public static void editPhotoDetails(Context c, Photo p){
		Intent intent = new Intent(c, PhotoDetailsEdit.class);
		intent.putExtra("photo", p);
		c.startActivity(intent);
	}
	
	public static void showPhoto(Context c, Photo p){
		Intent intent = new Intent(c, PhotoView.class);
		intent.putExtra("photo", p);
		c.startActivity(intent);
	}
	
	public static void showEffectsPhoto(Context c, Photo p){
		Intent intent = new Intent(c, EffectsPhotoView.class);
		intent.putExtra("photo", p);
		c.startActivity(intent);
	}
	
	public static void showDrawPhoto(Context c, Photo p){
		Intent intent = new Intent(c, DrawPhotoView.class);
		intent.putExtra("photo", p);
		c.startActivity(intent);
	}
	
	public static void showError(Context c, String errorMsg){
		AlertDialog.Builder builder = new AlertDialog.Builder(c);
		builder.setMessage(errorMsg)
			   .setTitle("Oooops...")
		       .setCancelable(false)
		       .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
		           public void onClick(DialogInterface dialog, int id) {
		                dialog.cancel();
		           }
		       });
		builder.show();
	}

	public static void showShareFb(Context c, Photo p) {
		Intent intent = new Intent(c, ShareFbView.class);
		intent.putExtra("photo", p);
		c.startActivity(intent);
	}
	
	public static void showRotate(Context c, Photo p) {
		Intent intent = new Intent(c, RotatePhotoView.class);
		intent.putExtra("photo", p);
		c.startActivity(intent);
	}
}
